package com.scz.util;

import com.scz.entity.UserInfo;

public class UserInfoThreadLocal {
    // 创建一个 ThreadLocal 实例，用于存储 userName
    private static final ThreadLocal<String> userInfoThreadLocal = new ThreadLocal<>();

    // 设置当前线程的登录用户信息
    public static void setUserInfo(String userInfo) {
        userInfoThreadLocal.set(userInfo);
    }

    // 获取当前线程的登录用户信息
    public static String getUserInfo() {
        return userInfoThreadLocal.get();
    }

    // 清除当前线程的登录用户信息，防止内存泄漏
    public static void clearUserInfo() {
        userInfoThreadLocal.remove();
    }
}